package apiday06.thread;

import java.util.Scanner;

public class SleepDemo {
    public static void main(String[] args) {
        System.out.println("程序开始了！");
        Scanner sc = new Scanner(System.in);
        System.out.println("输入倒计时的时间：（秒）");
        int time = sc.nextInt();
        long start = System.currentTimeMillis();
        for (int i = time; i > 0; i--) {
            System.out.println(i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("0\n时间到！");
        long end = System.currentTimeMillis();
        System.out.println("程序结束了！持续：" + (end - start) / 1000 + "秒");
        sc.close();
    }
}
